
clear all
set more off
cap log close

ssc install unique
    
global dir "/Replication Archive"
cd "${dir}"

global outreg_settings = " label bdec(4) pvalue pdec(3) tex(frag) excel  nor2 nonotes "

*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************
*********************     		 MAIN TABLES AND FIGURES FOR THE PAPER   	    *************************
*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************

************************************
************* TABLE 4 *************
************************************

	
use "${dir}/Data/Final Datasets/Contributions_Final_Committee_Analysis.dta", clear
collapse (sum) amount_noself, by(DirectorID cycle)
tempfile temp
save "`temp'" , replace 
use "${dir}/Data/Final Datasets/Directors_Information.dta", clear
merge m:1 DirectorID cycle using "`temp'"
drop if _m==2
drop _m
replace amount_noself=0 if amount_noself==.
merge m:1 CompanyID cycle using "${dir}/Data/AUX/lobbying_firms_list_cycle.dta"
keep if _m==3
drop _m
gen donated=(amount_noself>0)
label var donated "Donated"
label var amount_noself "\$ Amount"
label var lobbying_firm "Lobbying"
preserve
collapse (first) donated amount_noself (max) lobbying_firm, by(DirectorID cycle)
label var donated "Donated"
label var amount_noself "\$ Amount"
reghdfe donated lobbying_firm, absorb(DirectorID cycle) cluster(DirectorID)  keepsingletons
su donated if lobbying_firm==0 &  e(sample)==1
local mean: display %5.3fc `r(mean)' 
local b = _b[lobbying_firm]
gen b_st=`b'/`mean'*100
su b_st
local b_st: display %5.1fc `r(mean)'
outreg2 using "${dir}/Results/Table4.tex", se bdec(3) keep(lobbying_firm) ///
		addtext(Individual FE, Yes, Cycle FE, Yes, Individual-Company FE, No, Cycle-Industry FE, No, % Increase, `b_st'% ) ///
		nocons pvalue label
restore

preserve
collapse (first) donated amount_noself (max) lobbying_firm, by(DirectorID cycle)
label var donated "Donated"
label var amount_noself "\$ Amount"
reghdfe amount_noself lobbying_firm, absorb(DirectorID cycle) cluster(DirectorID)  keepsingletons
su amount_noself if lobbying_firm==0 &  e(sample)==1
local mean: display %5.3fc `r(mean)' 
local b = _b[lobbying_firm]
gen b_st=`b'/`mean'*100
su b_st
local b_st: display %5.1fc `r(mean)'
outreg2 using "${dir}/Results/Table4.tex", se bdec(3) keep(lobbying_firm) ///
		addtext(Individual FE, Yes, Cycle FE, Yes, Individual-Company FE, No, Cycle-Industry FE, No, % Increase, `b_st'% ) ///
		nocons pvalue label
restore

egen industry_cycle=group(industry cycle)
egen Director_Company=group(DirectorID CompanyID)

reghdfe donated lobbying_firm, absorb(Director_Company cycle) cluster(DirectorID)  keepsingletons
su donated if lobbying_firm==0 &  e(sample)==1
local mean: display %5.3fc `r(mean)' 
local b = _b[lobbying_firm]
gen b_st=`b'/`mean'*100
su b_st
local b_st: display %5.1fc `r(mean)'
outreg2 using "${dir}/Results/Table4.tex", se bdec(3) keep(lobbying_firm) ///
		addtext(Individual FE, No, Cycle FE, Yes, Individual-Company FE, Yes, Cycle-Industry FE, No, % Increase, `b_st'% ) ///
		nocons pvalue label
drop b_st
reghdfe amount_noself lobbying_firm, absorb(Director_Company cycle) cluster(DirectorID)  keepsingletons
su amount_noself if lobbying_firm==0 &  e(sample)==1
local mean: display %5.3fc `r(mean)' 
local b = _b[lobbying_firm]
gen b_st=`b'/`mean'*100
su b_st
local b_st: display %5.1fc `r(mean)'
outreg2 using "${dir}/Results/Table4.tex", se bdec(3) keep(lobbying_firm) ///
		addtext(Individual FE, No, Cycle FE, Yes, Individual-Company FE, Yes, Cycle-Industry FE, No, % Increase, `b_st'% ) ///
		nocons pvalue label
drop b_st
		
reghdfe donated lobbying_firm, absorb(Director_Company industry_cycle) cluster(DirectorID)  keepsingletons
su donated if lobbying_firm==0 &  e(sample)==1
local mean: display %5.3fc `r(mean)' 
local b = _b[lobbying_firm]
gen b_st=`b'/`mean'*100
su b_st
local b_st: display %5.1fc `r(mean)'
outreg2 using "${dir}/Results/Table4.tex", se bdec(3) keep(lobbying_firm) ///
		addtext(Individual FE, No, Cycle FE, No, Individual-Company FE, Yes, Cycle-Industry FE, Yes, % Increase, `b_st'% ) ///
		nocons pvalue label
drop b_st				
		
reghdfe amount_noself lobbying_firm, absorb(Director_Company industry_cycle) cluster(DirectorID)  keepsingletons
su amount_noself if lobbying_firm==0 &  e(sample)==1
local mean: display %5.3fc `r(mean)' 
local b = _b[lobbying_firm]
gen b_st=`b'/`mean'*100
su b_st
local b_st: display %5.1fc `r(mean)'
outreg2 using "${dir}/Results/Table4.tex", se bdec(3) keep(lobbying_firm) ///
		addtext(Individual FE, No, Cycle FE, No, Individual-Company FE, Yes, Cycle-Industry FE, Yes, % Increase, `b_st'% ) ///
		nocons pvalue label		
		
		
